var {apikey} = require("./utils/util.js")
App({
  globalData: {
    currentCity:""
  },
  onLaunch() {
    wx.getLocation({
      type: 'wgs84', 
      success: (res)=>{
        var {latitude, longitude} = res
        var url= `https://apis.map.qq.com/ws/geocoder/v1/?location=${latitude},${longitude}&key=${apikey}&get_poi=1`
        wx.request({
          url,
          header: {'content-type':'application/json'},
          method: 'GET',
          dataType: 'json',
          responseType: 'text',
          success: (res)=>{
            if(this.callback){
              var city = res.data.result.address_component.city
              wx.setStorageSync('locationCity', city)
              this.globalData.currentCity = city
              this.callback()
            }
          }
        });
      }
    })
    
  }
})
